#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int m[100];
	for (int i = 0; i < a; i++) {
		scanf("%d", &m[i]);
	}
	int n[100];
	for (int i = 0; i < b; i++) {
		scanf("%d", &n[i]);
	}

	int num[200];
	int p1 = 0, p2 = 0, p3 = 0;
	while (p1<a && p2<b) {
		if (m[p1] < n[p2]) {
			num[p3] = m[p1];
			p1++;
			p3++;
		}
		else if (m[p1] > n[p2]) {
			num[p3] = n[p2];
			p2++;
			p3++;
		}
		else {
			num[p3] = m[p1];
			p3++;
			num[p3] = n[p2];
			p3++;
		}
	}

	for (int i = 0; i < a + b; i++) {
		printf("%d ", num[i]);
	}
	return 0;
}